import java.io.StringWriter;
import java.io.PrintWriter;
public class Think_3_36
{
    //注意，所有的类我应该是都实现啦深拷贝，如果你发现没有，说明写错啦
    //注意，所有的缩放参数都是小数，1表示不缩放，0.9表示缩小为原来0.9倍，1.2表示放大为原来的1.2倍，以此类推
    private static void outPut(String s)
    {
        StackTraceElement ste=new Throwable().getStackTrace()[1];
        System.out.println(String.format("%4d",ste.getLineNumber())+"| "+s);
    }

    public static void main(String[] args)
    {
        ClosedFigure tri;
        System.out.println("line|测试项");
        System.out.println("    |==============================下面针对13个类进行测试===========================================");
        System.out.println("    |====由于Figure和ClosedFigure是抽象类无法实例化，加上一个点类不在书上的那个继承树里，故对12个类进行测试====");
        System.out.println("    | Point               | Line                | Rectangle           | Square");
        System.out.println("    | Ellipse             | Circle              | Triangle            | EquilateralTriangle");
        System.out.println("    | RightAngleTriangle  | Polygon             | RegularPolygon      | Pentagram");
        //点
        System.out.println("====|===========================================================================================");
        outPut("点的测试");
        System.out.println("====|===========================================================================================");
        outPut("  "+"点旋转");
        outPut("    "+"(1,1)点绕原点转90                  :"+new Point(1,1).revolve(Math.PI/2));
        outPut("    "+"(1,1)点绕原点转45                  :"+new Point(1,1).revolve(Math.PI/4));
        outPut("    "+"(1,1)点绕(2,2)转90                :"+new Point(1,1).revolve(new Point(2,2),Math.PI/2));
        outPut("    "+"(1,1)点绕(1,2)转90                :"+new Point(1,1).revolve(new Point(1,2),Math.PI/2));
        outPut("    "+"(1,1)点绕(2,2)转45                :"+new Point(1,1).revolve(new Point(2,2),Math.PI/4));
        outPut("  "+"点缩放");
        outPut("    "+"(1,1)点以原点为中心扩大为原来2倍      :"+new Point(1,1).zoom(2));
        outPut("    "+"(1,1)点以原点为中心缩小为原来1/2倍    :"+new Point(1,1).zoom(0.5));
        outPut("    "+"(1,1)点以(2,2)为中心扩大为原来2倍    :"+new Point(1,1).zoom(new Point(2,2),2));
        outPut("    "+"(1,1)点以(2,2)为中心缩小为原来1/2倍  :"+new Point(1,1).zoom(new Point(2,2),0.5));
        outPut("    "+"(1,1)点以(1,2)为中心扩大为原来2倍    :"+new Point(1,1).zoom(new Point(1,2),2));
        //直线
        System.out.println("====|===========================================================================================");
        outPut("直线的测试");
        System.out.println("====|===========================================================================================");
        outPut("  "+"直线求长度");
        outPut("    "+"((0,1)(1,2))直线长度  :"+new Line(0,1,1,2).length());
        outPut("    "+"((0,0)(2,2))直线长度  :"+new Line(0,0,2,2).length());
        outPut("  "+"直线旋转");
        outPut("    "+"((0,1)(1,2))直线绕原点转90  :"+new Line(0,1,1,2).revolve(Math.PI/2));
        outPut("  "+"直线缩放");
        outPut("    "+"((0,1)(1,2))以原点为中心扩大为原来2倍  :"+new Line(0,1,1,2).zoom(2));
        outPut("  "+"直线求标准方程");
        outPut("    "+"((0,1)(1,2))的A  :"+new Line(0,1,1,2).getA());
        outPut("    "+"((0,1)(1,2))的B  :"+new Line(0,1,1,2).getB());
        outPut("    "+"((0,1)(1,2))的C  :"+new Line(0,1,1,2).getC());
        outPut("  "+"点在直线上");
        outPut("    "+"(1,1)在((0.0)(2,2))上  :"+new Line(0,0,2,2).contains(new Point(1,1)));
        outPut("    "+"(2,2)在((0.0)(2,2))上  :"+new Line(0,0,2,2).contains(new Point(2,2)));
        outPut("    "+"(3,3)在((0.0)(2,2))上  :"+new Line(0,0,2,2).contains(new Point(3,3)));
        outPut("    "+"(2,3)在((0.0)(2,2))上  :"+new Line(0,0,2,2).contains(new Point(2,3)));
        outPut("  "+"点在线段内");
        outPut("    "+"(1,1)在((0.0)(2,2))内  :"+new Line(0,0,2,2).onSegment(new Point(1,1)));
        outPut("    "+"(2,2)在((0.0)(2,2))内  :"+new Line(0,0,2,2).onSegment(new Point(2,2)));
        outPut("    "+"(3,3)在((0.0)(2,2))内  :"+new Line(0,0,2,2).onSegment(new Point(3,3)));
        outPut("    "+"(2,3)在((0.0)(2,2))内  :"+new Line(0,0,2,2).onSegment(new Point(2,3)));
        outPut("  "+"直线相交");
        outPut("    "+"两条相等的    :"+new Line(0,0,1,1).intersects(new Line(0,0,1,1)));
        outPut("    "+"两条平行的    :"+new Line(0,0,1,1).intersects(new Line(1,1,2,2)));
        outPut("    "+"两条相交的    :"+new Line(0,0,1,1).intersects(new Line(1,1,2,0)));
        outPut("    "+"竖着的水平的  :"+new Line(0,1,0,2).intersects(new Line(1,0,2,0)));
        outPut("  "+"点到直线距离");
        outPut("    "+"(1,1)到((0.0)(2,2))距离  :"+new Line(0,0,2,2).distance(new Point(1,1)));
        outPut("    "+"(2,3)到((0.0)(2,2))距离  :"+new Line(0,0,2,2).distance(new Point(2,3)));
        //矩形
        System.out.println("====|===========================================================================================");
        outPut("矩形的测试 "+(tri=new Rectangle(new Point(1,1),4,2)));
        System.out.println("====|===========================================================================================");
        outPut("  "+"矩形的周长                  :"+tri.perimeter());
        outPut("  "+"矩形的面积                  :"+tri.area());
        outPut("  "+"矩形绕中心转90              :"+tri.revolve(Math.PI/2));
        outPut("  "+"矩形绕原点转90              :"+tri.revolve(new Point(0,0),Math.PI/2));
        outPut("  "+"矩形以中心为中心扩大为原来2倍  :"+tri.zoom(2));
        outPut("  "+"矩形以原点为中心扩大为原来2倍  :"+tri.zoom(new Point(0,0),2));
        outPut("  "+"矩形包含(0,0)              :"+tri.contains(new Point(0,0)));
        outPut("  "+"矩形包含(1,1)              :"+tri.contains(new Point(1,1)));
        outPut("  "+"矩形包含(2,2)              :"+tri.contains(new Point(2,2)));
        //正方形
        System.out.println("====|===========================================================================================");
        outPut("正方形的测试 "+(tri=new Square(new Point(1,1),4)));
        System.out.println("    | 没有新方法，略");
        //椭圆
        System.out.println("====|===========================================================================================");
        outPut("椭圆的测试 "+(tri=new Ellipse(new Point(1,1),4,2)));
        System.out.println("====|===========================================================================================");
        outPut("  "+"椭圆的周长                  :"+tri.perimeter());
        outPut("  "+"椭圆的面积                  :"+tri.area());
        outPut("  "+"椭圆包含(0,0)              :"+tri.contains(new Point(0,0)));
        outPut("  "+"椭圆包含(1,1)              :"+tri.contains(new Point(1,1)));
        outPut("  "+"椭圆包含(2,2)              :"+tri.contains(new Point(2,2)));
        //圆
        System.out.println("====|===========================================================================================");
        outPut("圆的测试 "+(tri=new Circle(new Point(1,1),4)));
        System.out.println("    | 没有新方法，略");
        //三角形
        System.out.println("====|===========================================================================================");
        outPut("三角形的测试 "+(tri=new Triangle(new Point(1,1),new Point(1,2),new Point(2,1))));
        System.out.println("====|===========================================================================================");
        outPut("  "+"三角形的周长                  :"+tri.perimeter());
        outPut("  "+"三角形的面积                  :"+tri.area());
        outPut("  "+"三角形绕顶点转90              :"+tri.revolve(Math.PI/2));
        outPut("  "+"三角形绕原点转90              :"+tri.revolve(new Point(0,0),Math.PI/2));
        outPut("  "+"三角形以顶点为中心扩大为原来2倍  :"+tri.zoom(2));
        outPut("  "+"三角形以原点为中心扩大为原来2倍  :"+tri.zoom(new Point(0,0),2));
        outPut("  "+"在不在三角形里面");
        outPut("    "+"在边上       :"+tri.contains(new Point(1.5,1.5)));
        outPut("    "+"在顶点上     :"+tri.contains(new Point(1,1)));
        outPut("    "+"在里面       :"+tri.contains(new Point(1.25,1.25)));
        outPut("    "+"在外面       :"+tri.contains(new Point(2,2)));
        outPut("    "+"在边延长线上  :"+tri.contains(new Point(1,3)));
        //等边三角形
        System.out.println("====|===========================================================================================");
        outPut("等边三角形的测试 "+(tri=new EquilateralTriangle(new Point(1,1),new Point(1,2),new Point(2,1))));
        System.out.println("    | 没有新方法，略");
        System.out.println("    | 显然这不是个等边三角形。。。");
        //直角三角形
        System.out.println("====|===========================================================================================");
        outPut("直角三角形的测试 "+(tri=new RightAngleTriangle(new Point(1,1),new Point(1,2),new Point(2,1))));
        System.out.println("    | 没有新方法，略");
        //多边形
        System.out.println("====|===========================================================================================");
        outPut("多边形的测试 "+(tri=new Polygon(new Point[]{new Point(1,1),new Point(1,2),new Point(2,1)})));
        System.out.println("====|===========================================================================================");
        outPut("  "+"多边形的周长                  :"+tri.perimeter());
        outPut("  "+"多边形的面积                  :"+tri.area());
        outPut("  "+"多边形绕顶点转90              :"+tri.revolve(Math.PI/2));
        outPut("  "+"多边形绕原点转90              :"+tri.revolve(new Point(0,0),Math.PI/2));
        outPut("  "+"多边形以顶点为中心扩大为原来2倍  :"+tri.zoom(2));
        outPut("  "+"多边形以原点为中心扩大为原来2倍  :"+tri.zoom(new Point(0,0),2));
        outPut("  "+"在不在多边形里面");
        outPut("    "+"在边上       :"+tri.contains(new Point(1.5,1.5)));
        outPut("    "+"在顶点上     :"+tri.contains(new Point(1,1)));
        outPut("    "+"在里面       :"+tri.contains(new Point(1.25,1.25)));
        outPut("    "+"在外面       :"+tri.contains(new Point(2,2)));
        outPut("    "+"在边延长线上  :"+tri.contains(new Point(1,3)));
        //正多边形
        System.out.println("====|===========================================================================================");
        outPut("正多边形的测试 "+(tri=new RegularPolygon(new Point[]{new Point(1,1),new Point(1,2),new Point(2,1)})));
        System.out.println("    | 没有新方法，略");
        //五角星
        System.out.println("====|===========================================================================================");
        outPut("五角星的测试 "+(tri=new Pentagram(new Point[]{new Point(1,1),new Point(1,2),new Point(2,1)})));
        System.out.println("    | 没有新方法，略");
        System.out.println("====|===========================================================================================");

        //矩形
        System.out.println("====|===========================================================================================");
        outPut("附加的测试");
        System.out.println("====|===========================================================================================");
        tri=new Rectangle(new Point(1,0),new Point(3,1));
        outPut("  "+"矩形"+tri+"绕中心转90  :"+tri.revolve(new Point(2,0.5),Math.PI/2));

    }
}
